// router.js
import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

// 将router里面的所有路由都收集起来，集中导入
const modules = require.context('./modules', false, /\.js$/)
let allRoutes = []
modules.keys().forEach(key => {
  allRoutes = allRoutes.concat(modules(key).default)
})

const routes = [
  {
    path: '/',
    redirect: '/Home',
  },
  {
    path: '/Home',
    name: 'Home',
    component: () => import('@/views/Home'),
  },
  {
    path: '/Login',
    name: 'login',
    meta: {
      title: 'Login - 登录',
    },
    component: () => import('@/views/login/login2.vue'),
  },
  ...allRoutes,
]

const router = new Router({
  mode: 'history', // 可选，使用 HTML5 的历史模式
  routes,
})

export default router
